﻿#pragma once
#define _USE_MATH_DEFINES
#include <cmath>
#include <list>
#include <d3dx9.h>
using namespace std;
class StaticObject;
class Box;
#define g -0.3f
#define dy 0.03f
#define v_fall_run 2.5f
#define  D_NEAR 5
enum MOVE_STATE
{
	ON_GROUND,ON_WATER, ON_SPACE, CLIMB_LEFT,FALL_DOWN ,CLIMB_RIGHT, SPACE_GROUND, SPACE_WATER, SPACE_NONE
};
class MoveObject
{
private:		
	Box* _mBox;//	
	float _angle;//		
	void _increaseAngle();		
	Box* _boundBox;
	Box* _moveBox;
	
	
	//cho dung hien tai
	StaticObject* _currentGround;
	StaticObject* _fallFromGround;
	//roi tu do
	void _fallDown(float remainTime);	
	MOVE_STATE _groundingState;

protected:	
	int _direction;
	MOVE_STATE _moveState;
	Box* _getBoundBox();//dung cho Quadtree
	Box* _getGround();
	Box* _getMoveBox();
	StaticObject* _getCurrentGround();
public:		
	MoveObject();
	bool AssignMove(Box* parentBox);	
	void moveLeft();
	void moveRight();
	void moveSinY(int a);
	void moveTo(float time,D3DXVECTOR2 target);
	void moveFollowAngle( float angle);
	//bool moveDiagonalThrow(float angle, float groundLevel);
	void moveDiagonalThrow(float angle);
	void move();		
	void fallDown();
	//vui lắm
	~MoveObject(void);	
	bool checkOutGround();
	bool isOnSpace();
	bool isOnWater();
	bool isOnGround();
	MOVE_STATE isGrounding();
	bool canFallDown();
	bool moveDiagonalThrow1(float angle);

};

